
import java.util.ArrayList;
import java.util.Random;
public class Game {
    public static void main(String[] args) {

        ArrayList<Card> cardList = Decoration();

        shuffle(cardList);

        ArrayList<Card> playerA = new ArrayList<>();
        ArrayList<Card> playerB = new ArrayList<>();
        ArrayList<Card> playerC = new ArrayList<>();

        System.out.println("抓牌前:");
        System.out.println("牌堆有"+cardList.size()+"张牌:"+cardList);


        for (int i = 0; i < 5; i++) {
            Card card = cardList.remove(0);
            playerA.add(card);

            card = cardList.remove(0);
            playerB.add(card);

            card = cardList.remove(0);
            playerC.add(card);
        }

        System.out.println("抓牌后:");
        System.out.println("牌堆有"+cardList.size()+"张牌:"+cardList);
        System.out.println("玩家A: "+playerA);
        System.out.println("玩家B: "+playerB);
        System.out.println("玩家C: "+playerC);
    }
    private static void shuffle(ArrayList<Card> cardList) {
        Random random = new Random();
        for (int i = cardList.size() - 1; i > 0; i--) {
            Card aCard = cardList.get(i);
            int randomIdx = random.nextInt(i);
            Card tmpA = cardList.get(i);
            Card tmpB = cardList.get(randomIdx);
            cardList.set(i, tmpB);
            cardList.set(randomIdx, tmpA);
        }
    }
    private static ArrayList<Card> Decoration() {
        ArrayList<Card> cardList = new ArrayList<>();
        String[] suits = {"♥", "♠", "♣", "♦"};
        for (String suit : suits) {
            for (int rank = 1; rank <= 13; rank++) {
                Card card = new Card(rank, suit);
                cardList.add(card);
            }
        }
        return cardList;
    }
}